<template>
	<div>
		<el-form ref="form" :model="form" label-width="100px">
			<el-form-item label="管家姓名" prop="name">
				<el-select v-model="form.name" placeholder="请选择管家" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in HealthHousekeeperData" :key="index" :label="item.staffName"
						:value="item.staffName" :disabled="item.disabled"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="用户名称" prop="roleName">
				<el-input v-model="form.roleName"></el-input>
			</el-form-item>
			<el-form-item label="联系电话" prop="managerTel">
				<el-input v-model="form.managerTel"></el-input>
			</el-form-item>
			<el-form-item label="服务楼层" prop="serviceFloor">
				<el-input v-model="form.serviceFloor"></el-input>
			</el-form-item>
			<el-form-item label="备注" prop="note">
				<el-input v-model="form.note"></el-input>
			</el-form-item>
			<el-form-item label="操作时间" prop="operationTime">
				<el-input v-model="form.operationTime"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'ServiceObjectEdit',
		components: {
		},
		props: [
			'showEdit',
			'objectId',
			'editid'
		],
		data() {
			return {
				form: {
					objectId: '',
					name: '',
					roleName: '',
					managerTel: '',
					serviceFloor: '',
					note: '',
					operationTime: ''
				},
				// supdate: false,
				url: '/serviceObject/save',
				registerlevel: [],
				depts: [],
				HealthHousekeeperData: [],
			}
		},
		created() {
			// this.init()
			if (this.editid) {
				this.axios.get('/serviceObject/toedit', response => {
					this.form = response.obj
				}, {
					id: this.editid
				})
			}
			this.axios.get('/staffManagement/findHealthHousekeeper', response => {
				this.HealthHousekeeperData = response.obj
			})
		},
		methods: {
			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}

		}
	}
</script>

<style>
</style>
